/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package orm.impl;

import org.orm.*;
import org.hibernate.Query;
import java.util.List;
import orm.*;

public class Tbv_bitacora_reparacionDAOImpl implements orm.dao.Tbv_bitacora_reparacionDAO {
	public Tbv_bitacora_reparacion loadTbv_bitacora_reparacionByORMID(int re_id_bitacora_reparacion) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_bitacora_reparacionByORMID(session, re_id_bitacora_reparacion);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_reparacion getTbv_bitacora_reparacionByORMID(int re_id_bitacora_reparacion) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return getTbv_bitacora_reparacionByORMID(session, re_id_bitacora_reparacion);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_reparacion loadTbv_bitacora_reparacionByORMID(int re_id_bitacora_reparacion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_bitacora_reparacionByORMID(session, re_id_bitacora_reparacion, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_reparacion getTbv_bitacora_reparacionByORMID(int re_id_bitacora_reparacion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return getTbv_bitacora_reparacionByORMID(session, re_id_bitacora_reparacion, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_reparacion loadTbv_bitacora_reparacionByORMID(PersistentSession session, int re_id_bitacora_reparacion) throws PersistentException {
		try {
			return (Tbv_bitacora_reparacion) session.load(orm.Tbv_bitacora_reparacion.class, new Integer(re_id_bitacora_reparacion));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_reparacion getTbv_bitacora_reparacionByORMID(PersistentSession session, int re_id_bitacora_reparacion) throws PersistentException {
		try {
			return (Tbv_bitacora_reparacion) session.get(orm.Tbv_bitacora_reparacion.class, new Integer(re_id_bitacora_reparacion));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_reparacion loadTbv_bitacora_reparacionByORMID(PersistentSession session, int re_id_bitacora_reparacion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Tbv_bitacora_reparacion) session.load(orm.Tbv_bitacora_reparacion.class, new Integer(re_id_bitacora_reparacion), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_reparacion getTbv_bitacora_reparacionByORMID(PersistentSession session, int re_id_bitacora_reparacion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Tbv_bitacora_reparacion) session.get(orm.Tbv_bitacora_reparacion.class, new Integer(re_id_bitacora_reparacion), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_reparacion[] listTbv_bitacora_reparacionByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return listTbv_bitacora_reparacionByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_reparacion[] listTbv_bitacora_reparacionByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return listTbv_bitacora_reparacionByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_reparacion[] listTbv_bitacora_reparacionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_bitacora_reparacion as Tbv_bitacora_reparacion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			List list = query.list();
			return (Tbv_bitacora_reparacion[]) list.toArray(new Tbv_bitacora_reparacion[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_reparacion[] listTbv_bitacora_reparacionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_bitacora_reparacion as Tbv_bitacora_reparacion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			List list = query.list();
			return (Tbv_bitacora_reparacion[]) list.toArray(new Tbv_bitacora_reparacion[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_reparacion loadTbv_bitacora_reparacionByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_bitacora_reparacionByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_reparacion loadTbv_bitacora_reparacionByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_bitacora_reparacionByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_reparacion loadTbv_bitacora_reparacionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		Tbv_bitacora_reparacion[] tbv_bitacora_reparacions = listTbv_bitacora_reparacionByQuery(session, condition, orderBy);
		if (tbv_bitacora_reparacions != null && tbv_bitacora_reparacions.length > 0)
			return tbv_bitacora_reparacions[0];
		else
			return null;
	}
	
	public Tbv_bitacora_reparacion loadTbv_bitacora_reparacionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		Tbv_bitacora_reparacion[] tbv_bitacora_reparacions = listTbv_bitacora_reparacionByQuery(session, condition, orderBy, lockMode);
		if (tbv_bitacora_reparacions != null && tbv_bitacora_reparacions.length > 0)
			return tbv_bitacora_reparacions[0];
		else
			return null;
	}
	
	public static java.util.Iterator iterateTbv_bitacora_reparacionByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return iterateTbv_bitacora_reparacionByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTbv_bitacora_reparacionByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return iterateTbv_bitacora_reparacionByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTbv_bitacora_reparacionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_bitacora_reparacion as Tbv_bitacora_reparacion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTbv_bitacora_reparacionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_bitacora_reparacion as Tbv_bitacora_reparacion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_reparacion createTbv_bitacora_reparacion() {
		return new orm.Tbv_bitacora_reparacion();
	}
	
	public boolean save(orm.Tbv_bitacora_reparacion tbv_bitacora_reparacion) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().saveObject(tbv_bitacora_reparacion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean delete(orm.Tbv_bitacora_reparacion tbv_bitacora_reparacion) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().deleteObject(tbv_bitacora_reparacion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Tbv_bitacora_reparacion tbv_bitacora_reparacion)throws PersistentException {
		try {
			if(tbv_bitacora_reparacion.getTbv_bitacora_maquinabm_id_bitacora_maquina() != null) {
				tbv_bitacora_reparacion.getTbv_bitacora_maquinabm_id_bitacora_maquina().tbv_bitacora_reparacion.remove(tbv_bitacora_reparacion);
			}
			
			return delete(tbv_bitacora_reparacion);
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Tbv_bitacora_reparacion tbv_bitacora_reparacion, org.orm.PersistentSession session)throws PersistentException {
		try {
			if(tbv_bitacora_reparacion.getTbv_bitacora_maquinabm_id_bitacora_maquina() != null) {
				tbv_bitacora_reparacion.getTbv_bitacora_maquinabm_id_bitacora_maquina().tbv_bitacora_reparacion.remove(tbv_bitacora_reparacion);
			}
			
			try {
				session.delete(tbv_bitacora_reparacion);
				return true;
			} catch (Exception e) {
				return false;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean refresh(orm.Tbv_bitacora_reparacion tbv_bitacora_reparacion) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().getSession().refresh(tbv_bitacora_reparacion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean evict(orm.Tbv_bitacora_reparacion tbv_bitacora_reparacion) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().getSession().evict(tbv_bitacora_reparacion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_reparacion loadTbv_bitacora_reparacionByCriteria(Tbv_bitacora_reparacionCriteria tbv_bitacora_reparacionCriteria) {
		Tbv_bitacora_reparacion[] tbv_bitacora_reparacions = listTbv_bitacora_reparacionByCriteria(tbv_bitacora_reparacionCriteria);
		if(tbv_bitacora_reparacions == null || tbv_bitacora_reparacions.length == 0) {
			return null;
		}
		return tbv_bitacora_reparacions[0];
	}
	
	public Tbv_bitacora_reparacion[] listTbv_bitacora_reparacionByCriteria(Tbv_bitacora_reparacionCriteria tbv_bitacora_reparacionCriteria) {
		return tbv_bitacora_reparacionCriteria.listTbv_bitacora_reparacion();
	}
}
